<?php
/**
 * This class is used for storing every data in a row and generate the string depending on the format 
 * selected by the user
 * @author Daniel Rivera
 */
class Leaf {
	var $values;
	var $attributes;
	var $name;
	
	/**
	 * Setter method for the output name
	 * @param tablename Name of the table where this element was found in
	 */
	public function setName($tablename) {
		if (is_string( $tablename ) && $tablename != '') {
			//... TODO: quitar el plural
		}
		$name = 'element';
	}
	
	/**
	 * Use this method indicating the type of output file you wish, to obtain a string
	 * with object's values in the selected type (xml, json).
	 * @param format Type of output format
	 */
	public function toString($format) {
		switch ($format) {
			case 'xml':
				
				break;
			
			case 'json':
				$outputString = '"' . $name . '" : { ';
				break;
		}
		for ($i=0; $i < len($this ->values); $i++) { 
			switch ($format) {
				case 'xml':
					
					break;
				case 'json':
					$outputString .= '"' . $this ->attributes[i] . '" : "' . $this ->values[i] . '"';
					if (i <> len($this ->values) - 1) {
						$outputString .= ', \n';
					}
					break;
			}
		}
		return $outputString;
	}
}

?>